package com.toijng.weixintracker.entity;

import android.util.Log;

import java.util.ArrayList;

/**
 * Created by lizhuo on 16/7/28.
 */
public class Bag {

    public ArrayList<BagItem>  detail;

    public Bag(ArrayList<BagItem> detail) {
        this.detail = detail;
    }

    public Bag() {
        this.detail=new ArrayList<>();
    }

    public Boolean equal(Bag bag)
    {

        if (bag.detail!=null&&this.detail!=null) {
            for (BagItem bagItem : bag.detail) {
                for (BagItem ownItem : this.detail) {
                    if ((bagItem.getUsername().equals(ownItem.getUsername())) && (bagItem.getTime().equals(ownItem.getTime()))) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    public ArrayList<BagItem> getDetail() {
        return detail;
    }

    public void setDetail(ArrayList<BagItem> detail) {
        this.detail=new ArrayList<>();
        this.detail.addAll(detail);
    }


    public void clear()
    {
        this.detail=null;
    }

    @Override
    public String toString() {

        String  a="Bag:";
        for (BagItem ownItem : this.detail)
        {
            a=a+ownItem.toString();

        }

        return a;
    }
}
